﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.mMall.Seller
{
	public partial class mfRefundInfo : msBsc.Cls.mBPDealer
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

        private void getRefundInfo()
        {
            string orderId = this.GetParamHtValue("orderId");
            if (string.IsNullOrEmpty(orderId))
            {
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizCustomerRefund customerRefund = new AppLogic.DataAlc.CBizCustomerRefund())
            {
                DataSet ds = customerRefund.GetRefundInfoByOrderId(orderId);
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    return;
                }
                string ret = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");
                this.ExecJScript(@"setReason(" + ret + ")");
            }
        }

        private void checkRefund()
        {
            string orderId = this.GetParamHtValue("orderId");
            if (string.IsNullOrEmpty(orderId))
            {
                this.Alert("订单号不能为空");
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizCustomerRefund refund = new AppLogic.DataAlc.CBizCustomerRefund())
            {
                string ret = refund.CheckRefund(orderId);
                if (ret != "OK")
                {
                    this.Alert(ret);
                    return;
                }
                else
                {
                    this.ExecJScript(@"alert(""确认退款成功"");window.location.href = ""/ms_OrderInfo.htm?orderId=" + orderId + @"""");
                }
            }
        }

        public override void DoAction()
        {
            if (this.strAction == "checkRefund")
            {
                checkRefund();
            }
            else if (this.strAction=="getRefund")
            {
                getRefundInfo();
            }
        }
	}
}